package com.yuhs.zixing.study.design.pattern.dp001.principle.p03.dependency.inversion;

/**
 * @description 依赖传递 构造器传递
 * @author: yuhs
 * @date 2022/3/25 下午8:09
 */
public class DependencyPassDemo002 {
    public static void main(String[] args) {

        ChangHong2 changHong = new ChangHong2();
        OpenAndClose2 openAndClose = new OpenAndClose2(changHong);
        openAndClose.open();
    }
}


interface TVInterface2 {
    void play();
}

class ChangHong2 implements TVInterface2 {
    @Override
    public void play() {
        System.out.println("长虹电视播放西游记");
    }
}


interface OpenAndCloseInterface2 {
    void open();
}

class OpenAndClose2 implements OpenAndCloseInterface2 {
    public TVInterface2 tvInterface2;

    public OpenAndClose2(TVInterface2 tvInterface2) {
        this.tvInterface2 = tvInterface2;
    }

    @Override
    public void open() {
        tvInterface2.play();
    }
}
